// @ts-ignore
import { RequestOptions } from './RequestOption';
import { httpCore as HttpCore } from './HttpCore';
import {ClassConstructor, plainToInstance} from 'class-transformer';
import { BaseResponse } from './BaseResponse';
import PageList from './PageList';
/**
 * <pre>
 * @desc       : 对外管理器
 * </pre>
 */
export class HttpManager {
  private static mInstance: HttpManager;

  // 防止实例化
  private constructor() {
  }

  static getInstance(): HttpManager {
    if (!HttpManager.mInstance) {
      HttpManager.mInstance = new HttpManager();
    }
    return HttpManager.mInstance;
  }

  request<T>(option: RequestOptions,type:ClassConstructor<T>): Promise<BaseResponse<T>> {
    return HttpCore.request(option,type);
  }
  requestList<T>(option: RequestOptions,type:ClassConstructor<T>): Promise<BaseResponse<PageList<T>>> {
    return HttpCore.requestList(option,type);
  }
}
